package com.javasea.spring.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 事件的发布者，并注入ApplicationEventPublisher
 * @Author longxiaonan@163.com
 * @Date 15:20 2022/3/23 0023
 **/
@Slf4j
@Component
public class ReconnectEventPublisher {

   @Resource
   ApplicationEventPublisher applicationEventPublisher;

   public void publishEvent(String message) {
       log.info("开始发布重连事件");
       ReconnectApplicationEvent reconnectApplicationEvent = new ReconnectApplicationEvent(this, message);
       // 发布事件
       applicationEventPublisher.publishEvent(reconnectApplicationEvent);
       log.info("发布重连事件结束");
  }

}
